import { FormActionType } from '/@/components/Form/index';

import type { TableActionType } from '/@/components/Table';

export interface FormState {
  isUpdate?: boolean;
  readonly?: boolean;
  partReadonly?: boolean;
  preview?: boolean;
  moduleId: string;
  modelId: string;
  hideFields: Indexable[];
  showFields: Indexable[];
  hideParams: Indexable;
  params?: Indexable;
  echoData?: Indexable;
  apiFn?: PromiseFn;
  rangeTimeMap: Map<any, any>;
  userInfo: Indexable;
}

export interface ModalParams {
  moduleId?: string;
  modelId?: string;
  isComplex?: boolean;
  preview?: boolean;
  param?: string;
  dynamicParams?: string;
  query?: string;
  parentQuery?: string;
  parentParam?: string;
  isUpdate?: boolean;
  detail?: boolean;
  record?: Indexable;
  width?: string;
  height?: string;
  showTitle?: boolean;
  searchDefaultParam?: Object;
}

export interface ActionModel {
  primaryKey: string;
  tableModelId: string | number;
  moduleId: string | number;
  record: Indexable;
}

export interface ActionItemModel {
  primaryKeys?: Recordable;
  record: Indexable;
}

export interface SearchColumn {
  dataIndex: string;
  title: string;
  event?: string;
  searchType: number;
  options: any[];
  labelSpan: number;
  colNum: number;
  displayCondition: any[];
  relaTableInfo: Recordable;
}

export type Callback = (
  opt?: any,
) => Promise<any> | void | (TableActionType & { getForm: () => FormActionType });

export interface InitModalParams {
  moduleId: string;
  dataModelId: string;
  params?: Indexable;
  isUpdate?: boolean;
  width?: string | number;
  placement?: string;
  disabled?: boolean;
  readonly?: boolean;
  partReadonly?: boolean;
  preview?: boolean;
  parentFormActionType?: Partial<FormActionType>;
}

export enum ComponentTypeEnum {
  'Input',
  'InputNumber',
  'ApiSelect',
  'ApiTreeSelect',
  'RadioGroup',
  'CheckboxGroup',
  'DatePicker',
  'Switch',
  'Upload',
  'IconPicker',
  'InputTextArea',
  'InputPassword',
  'RangePicker',
  'Hide',
  'HChooseUser',
  'SubTable',
  'HChooseDept',
  'HChooseRole',
  'HChoosePost',
  '综合角色选择(占位 后期加组件)',
  '部门-岗位-人员（待定 占位 后期加组件）',
  'HChooseComprehensiveBase',
  'HChooseUserAll',
  '部门-岗位(占位 后期加组件)',
  'TimePicker',
  'TimeRangePicker',
  'ScanCode',
  'IdentityCard',
  'Signature',
  'HFormTitle',
  'Map',
  'HButton',
  'HButtonZOffice',
}

export enum SEARCH_TYPE {
  'DISABLED',
  'CONDITON' = 3,
  'OPTIONS' = 5,
  'DATE' = 6,
  'DICT' = 7,
  'REAL_TABLE' = 8,
}

export enum LIST_FIELD_TYPE {
  'LINK_FIELD_TYPE' = 1, // 链接字段类型
  'FUNCTION_FIELD_TYPE' = 2, // 前端执行函数
  'OPTION_FIELD_TYPE' = 3, // 分类值字段类型
  'IMG_FIELD_TYPE' = 4, // 图像字段类型
  'RELA_FIELD_TYPE' = 7, // 关联表字段类型
  'SUB_FIELD_TYPE' = 8, // 子表字段类型
  'FILE_REVIEW_TYPE' = 10, // 文件图象[文件链接]
  'MIX_FIELD_TYPE' = 11, // 复合字段类型
  'DICT_FIELD_TYPE' = 13, // 字典字段类型
  'SWITCH_FIELD_TYPE' = 15, // 开关字段类型
}

export enum LIST_DISPLAY_TYPE {
  'HIDE',
  'SHOW',
  'DEF_SHOW',
  'DEF_HIDE',
}

export enum DelBatchType {
  DELETE = 'delete',
  FLOWDELETE = 'flow-delete',
  FLOWHANDROUNDDELETE = 'flow-handround-delete',
}

export interface FlexProps {
  layout?: string;
  md?: number;
  flushItemProps?;
  itemColProps?;
  subLabelWidth?: string | number;
}

export interface CustomFnObjType {
  openModal?: Function;
  openDrawer?: Function;
  openPageDrawer?: Function;
  openDetail?: Function;
  openPage?: Function;
}

export enum CUSTOM_FN_TYPE {
  modal = 'openModal',
  page = 'openPageDrawer',
  drawer = 'openDrawer',
  detail = 'openDetail',
  custom = 'openPage',
}
export interface BtnEventContext {
  params?: Indexable;
  schema?: Indexable;
  tableActionType?: Partial<TableActionType>;
  formActionType?: Partial<FormActionType>;
}

export interface ApiSourceParam {
  apiCode: string;
  params?: Recordable;
  callbacks?: Recordable<Fn | PromiseFn>;
  callbackFn?: string;
  isCustom?: boolean;
}
